/*
 * error_code_def.hpp
 *
 *  Created on: Jun 21, 2022
 *      Author: r2h
 */

#ifndef COMMON_ERROR_CODE_DEF_HPP_
#define COMMON_ERROR_CODE_DEF_HPP_

namespace common
{
#define NO_ERROR							 	0x00000000
#define CPLUS_STD_EXCEPTION						0xC0000000
#define SYS_OUT_OF_RESOURCE						0xC0000001
#define SYS_OUT_OF_MEMORY						0xC0000002

#define PORT_NUMBER_OUT_OF_RANGE				0x80000000
#define MOXA_API_PORT_INIT_EXCEPTION			0x80000001
#define MOXA_API_PORT_OPEN_EXCEPTION			0x80000002
#define MOXA_API_PORT_MODE_EXCEPTION			0x80000003
#define MOXA_API_PORT_BAUDRATE_EXCEPTION		0x80000004
#define MOXA_API_PORT_DATABITS_EXCEPTION		0x80000005
#define MOXA_API_PORT_STOPBITS_EXCEPTION		0x80000006
#define MOXA_API_PORT_PARITY_EXCEPTION			0x80000007
#define SYS_SERIAL_PORT_OPERATION_EXCEPTION		0x80000008
#define SYS_SERIAL_PORT_OPERATION_TIMEOUT		0x80000009
#define MOXA_API_LED_INIT_EXCEPTION				0x8000000A
#define MOXA_API_LED_OP_EXCEPTION				0x8000000B

#define SYS_SOCKET_PORT_OPERATION_EXCEPTION		0x80000010
#define SYS_SOCKET_INVALID_IP_ADDR				0x80000011
#define SYS_SOCKET_PORT_OPERATION_TIMEOUT		0x80000012
#define SYS_SOCKET_PORT_CONNECT_TIMEOUT			0x80000013

#define MEM_ACCESS_OUT_OF_RANGE					0x80000020

#define INVALID_XML_CONFIGURATION_FILE			0x80000030
#define INVALID_PORT_ID							0x80000031
#define INVALID_PORT_MODE						0x80000032
#define INVALID_PORT_PARITY						0x80000033
#define INVALID_PORT_BAUDRATE					0x80000034
#define INVALID_PORT_DATABITS					0x80000035
#define INVALID_PORT_STOPBITS					0x80000036
#define INVALID_PORT_PRIORITY					0x80000037

#define INVALID_DEVICE_UNIT						0x80000038
#define INVALID_DEVICE_INSTANCE					0x80000039
#define INVALID_DEVICE_MODEL					0x8000003A
#define INVALID_DEVICE_RW_RANGE					0x8000003B
#define DEVICE_RANGE_OUT_OF_SERVER_MEMORY		0x8000003C
#define INVALID_DEVICE_RECV_TIMEOUT				0x8000003D
#define INVALID_DEVICE_SEND_TIMEOUT				0x8000003E
#define INVALID_DEVICE_PROHIBIT					0x8000003F

#define INVALID_ETHSERVER_PORT					0x80000040
#define INVALID_ETHSERVER_PROTOCOL				0x80000041
#define INVALID_ETHSERVER_CONCURRENT			0x80000042
#define INVALID_ETHSERVER_WKPRIORITY			0x80000043
#define INVALID_ETHSERVER_LSPRIORITY			0x80000044
#define INVALID_ETHSERVER_RECV_TIMEOUT			0x80000045
#define INVALID_ETHSERVER_SEND_TIMEOUT			0x80000046



#define MODBUS_RTU_READ_SIZE_OUT_OF_RANGE		0x80008000
#define MODBUS_RTU_SLV_ADDR_MISMATCH			0x80008001
#define MODBUS_RTU_FUNC_CODE_MISMATCH			0x80008002
#define MODBUS_RTU_REGISTER_CNT_MISMATCH		0x80008003
#define MODBUS_RTU_WRITE_SIZE_OUT_OF_RANGE		0x80008004
#define MODBUS_RTU_WRITE_RANGE_MISMATCH			0x80008005
#define MODBUS_RTU_CRC_ERROR					0x8000800F

#define MODBUS_ASC_INVALID_CHARACTER			0x80008010
#define MODBUS_ASC_CAN_NOT_FIND_TRAILER			0x80008011
#define MODBUS_ASC_READ_SIZE_OUT_OF_RANGE		0x80008012
#define MODBUS_ASC_WRITE_SIZE_OUT_OF_RANGE		0x80008013
#define MODBUS_ASC_SLV_ADDR_MISMATCH			0x80008014
#define MODBUS_ASC_FUNC_CODE_MISMATCH			0x80008015
#define MODBUS_ASC_REGISTER_CNT_MISMATCH		0x80008016
#define MODBUS_ASC_WRITE_RANGE_MISMATCH			0x80008017
#define MODBUS_ASC_LRC_ERROR					0x8000801F

#define SDE_RECV_INVALID_DATAGRAM				0x80004000
#define SDE_TRANSACTION_MISMATCH				0x80004001
#define SDE_FUNC_CODE_MISMATCH					0x80004002
#define SDE_AREA_ADDR_MISMATCH					0x80004003
#define SDE_NOT_EXPECTED_MSG_SIZE				0x80004004
#define SDE_READ_OUT_OF_RANGE					0x80004005
#define SDE_WRITE_OUT_OF_RANGE					0x80004006

#define SDE_SERVER_NOT_RUNNING					0x80004010
#define SDE_SERVER_IS_RUNNING					0x80004011

#define PORT_SCANNER_NOT_RUNNING				0x80004020
#define PORT_SCANNER_IS_RUNNING					0x80004021
#define PORT_SCANNER_IS_STOPPING				0x80004022
#define PORT_SCANNER_OUT_OF_SHARED_MEMORY		0x80004023
#define PORT_SCANNER_INVALID_PORT_ID			0x80004024
#define PORT_SCANNER_INVALID_DEV_MODEL			0x80004025
#define PORT_SCANNER_NODE_LIMIT_TRIGGERED		0x80004026
#define PORT_SCANNER_INVALID_SLV_PARAM			0x80004027
}

#endif /* COMMON_ERROR_CODE_DEF_HPP_ */
